<!-- File: /app/View/Sections/index.ctp -->
<h1>Preinscripción Académica</h1>
</br>
<h3><?php echo $this->PreinscriptionProcess->mensaje($proceso); ?></h3>
</br>
<?php if(sizeof($cursos) > 0){ ?>
<table>
    <tr>
        <th>Código</th>
        <th><?php echo $this->Paginator->sort('name','Nombre'); ?></th>
        <th>Profesor</th>
        <th>Horario</th>
        <th><?php echo $this->Paginator->sort('ud','Uds'); ?></th>
        <th><?php echo $this->Paginator->sort('is_mandatory','Obligatorio'); ?></th>
        <th>Acciones</th>
    </tr>
<?php 
$i = 0;


foreach($cursos as $curso){ 
    //foreach($curso['Code'] as $codigo){
        //foreach($curso['Section'] as $seccion){
?>
    <tr>
        <td><?php echo h($curso['CoursesCode'][0]['CoursesCode']['code'].'-'.$curso['Section']['section_number']);?></td>
        <td><?php echo h($curso['Course']['name']);?></td>
        <td> 
            
            <?php
                $i = 0;
                if(array_key_exists('User', $curso)){
                foreach($curso['User'] as $profe){
                    echo $profe['User']['first_name'].' '.$profe['User']['last_name'];
                    $i++;
                    if($i < sizeof($curso['User'])){
                        echo ' / ';
                    }
                }}       
                
            ?>
        </td>
        <td> 
            <?php
                $i = 0;
                $countScheduleOption = sizeof($curso['Scheduleoption']);
                foreach($curso['Scheduleoption'] as $schedule){
                    
                    echo explode(';',$schedule['Scheduleoption']['schedule'])[0];
                    $i++; 
                    if($i < $countScheduleOption){
                        echo ', ';
                    }       

                    
                    
                }
            ?>

        </td>
        <td> <?php echo h($curso['Course']['ud']);?> </td>
        <td> 
            <?php 
                if(h($curso['Course']['mandatory']) == 1)
                    echo 'Si';
                else
                    echo 'No';
                
            ;?> 
        </td>
        <td>
            
            <?php echo $this->Html->link('Editar', array('action'=>'edit', $curso['Section']['id'], $processId)); ?>
            &nbsp; 
            <?php echo $this->Form->postLink('Eliminar',
                array('action'=>'delete', $curso['Section']['id']),
                array('confirm' =>'¿Realmente desea eliminar el curso '.$curso['Course']['name'].' sección '.$curso['Section']['section_number'].'?'))
            ?>
            &nbsp;
            <?php //echo $this->Html->link('Ver Requisitos', array('action'=>'requisitos', $curso['Course']['id'])); ?>
        </td>
    </tr>
<?php }//}//} ?>
</table>

<p>
    <?php 
    echo $this->Paginator->counter(
        array('format'=>'Página {:page} de {:pages}, mostrando {:current} registros de {:count}')); 
    ?>
</p>
<div class='paging'>
    <?php echo $this->Paginator->prev('< anterior', array(), null, array('class'=>'prev disabled')); ?>
    <?php echo $this->Paginator->numbers(array('separator'=>'')); ?>
    <?php echo $this->Paginator->next('siguiente >', array(), null, array('class' =>'next disabled')); ?>
</div>
<?php }else{ ?>

<h4>No hay cursos disponibles para mostrar</h4>

<?php } ?>


<?php echo $this->Html->link('Volver', array('controller' => 'PreinscriptionProcesses','action' => 'edit_period')); ?> &nbsp;
<?php echo $this->Html->link('Agregar Curso', array('action' => 'add',$processId )); ?>
&nbsp;
<?php echo $this->Html->link('Cargar cursos desde excel', array('controller' =>'Courses', 'action' =>'index', $processId)); ?>
&nbsp;



